home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / awt / toolkit.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  6.2 KB  |  196 lines

  1. /*
  2.  * @(#)Toolkit.java    1.39 95/08/23 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.awt;
  21.  
  22. import java.awt.peer.*;
  23. import java.awt.image.ImageProducer;
  24.  
  25. /**
  26.  * An AWT toolkit. It is used to bind the abstract AWT classes
  27.  * to a particular native toolkit implementation.
  28.  *
  29.  * @version     1.39, 08/23/95
  30.  * @author    Sami Shaio
  31.  * @author    Arthur van Hoff
  32.  */
  33. public abstract class  Toolkit {
  34.  
  35.     /**
  36.      * Uses the specified Peer interface to create a new Button.
  37.      * @param target the Button to be created
  38.      */
  39.     protected abstract ButtonPeer     createButton(Button target);
  40.  
  41.     /**
  42.      * Uses the specified Peer interface to create a new TextField.      
  43.      * @param target the TextField to be created
  44.      */
  45.     protected abstract TextFieldPeer     createTextField(TextField target);
  46.  
  47.     /**
  48.      * Uses the specified Peer interface to create a new Label.      
  49.      * @param target the Label to be created
  50.      */
  51.     protected abstract LabelPeer     createLabel(Label target);
  52.  
  53.     /**
  54.      * Uses the specified Peer interface to create a new List.      
  55.      * @param target the List to be created
  56.      */
  57.     protected abstract ListPeer     createList(List target);
  58.  
  59.     /**
  60.      * Uses the specified Peer interface to create a new Checkbox.      
  61.      * @param target the Checkbox to be created
  62.      */
  63.     protected abstract CheckboxPeer     createCheckbox(Checkbox target);
  64.  
  65.     /**
  66.      * Uses the specified Peer interface to create a new Scrollbar.      
  67.      * @param target the Scrollbar to be created
  68.      */
  69.     protected abstract ScrollbarPeer     createScrollbar(Scrollbar target);
  70.  
  71.     /**
  72.      * Uses the specified Peer interface to create a new TextArea.      
  73.      * @param target the TextArea to be created
  74.      */
  75.     protected abstract TextAreaPeer      createTextArea(TextArea target);
  76.  
  77.     /**
  78.      * Uses the specified Peer interface to create a new Choice.      
  79.      * @param target the Choice to be created
  80.      */
  81.     protected abstract ChoicePeer    createChoice(Choice target);
  82.  
  83.     /**
  84.      * Uses the specified Peer interface to create a new Frame.
  85.      * @param target the Frame to be created
  86.      */
  87.     protected abstract FramePeer      createFrame(Frame target);
  88.  
  89.     /**
  90.      * Uses the specified Peer interface to create a new Canvas.
  91.      * @param target the Canvas to be created
  92.      */
  93.     protected abstract CanvasPeer     createCanvas(Canvas target);
  94.  
  95.     /**
  96.      * Uses the specified Peer interface to create a new Panel.
  97.      * @param target the Panel to be created
  98.      */
  99.     protected abstract PanelPeer      createPanel(Panel target);
  100.  
  101.     /**
  102.      * Uses the specified Peer interface to create a new Window.
  103.      * @param target the Window to be created
  104.      */
  105.     protected abstract WindowPeer      createWindow(Window target);
  106.  
  107.     /**
  108.      * Uses the specified Peer interface to create a new Dialog.
  109.      * @param target the Dialog to be created
  110.      */
  111.     protected abstract DialogPeer      createDialog(Dialog target);
  112.  
  113.     /**
  114.      * Uses the specified Peer interface to create a new MenuBar.
  115.      * @param target the MenuBar to be created
  116.      */
  117.     protected abstract MenuBarPeer      createMenuBar(MenuBar target);
  118.  
  119.     /**
  120.      * Uses the specified Peer interface to create a new Menu.
  121.      * @param target the Menu to be created
  122.      */
  123.     protected abstract MenuPeer      createMenu(Menu target);
  124.  
  125.     /**
  126.      * Uses the specified Peer interface to create a new MenuItem.
  127.      * @param target the MenuItem to be created
  128.      */
  129.     protected abstract MenuItemPeer      createMenuItem(MenuItem target);
  130.  
  131.     /**
  132.      * Uses the specified Peer interface to create a new FileDialog.
  133.      * @param target the FileDialog to be created
  134.      */
  135.     protected abstract FileDialogPeer    createFileDialog(FileDialog target);
  136.  
  137.     /**
  138.      * Uses the specified Peer interface to create a new CheckboxMenuItem.
  139.      * @param target the CheckboxMenuItem to be created
  140.      */
  141.     protected abstract CheckboxMenuItemPeer    createCheckboxMenuItem(CheckboxMenuItem target);
  142.  
  143.     /**
  144.      * Gets the size of the screen.
  145.      */
  146.     public abstract Dimension getScreenSize();
  147.  
  148.     /**
  149.      * Returns the screen resolution in dots-per-inch.
  150.      */
  151.     public abstract int getScreenResolution();
  152.  
  153.     /**
  154.      * Returns the names of the available fonts.
  155.      */
  156.     public abstract String[] getFontList();
  157.  
  158.     /**
  159.      * Syncs the graphics state, which is useful when doing animation.
  160.      */
  161.     public abstract void sync();
  162.  
  163.     /**
  164.      * The default toolkit.
  165.      */
  166.     private static Toolkit toolkit;
  167.  
  168.     /**
  169.      * Returns the default toolkit. This is controlled by the
  170.      * "awt.toolkit" property.
  171.      * @exception ClassNotFoundException If the toolkit is not found.
  172.      * @exception InstantiationException If the toolkit could not be instantiated.
  173.      */
  174.     public static synchronized Toolkit getDefaultToolkit() {
  175.     if (toolkit == null) {
  176.         String nm = System.getProperty("awt.toolkit", "sun.awt.motif.MToolkit");
  177.         try {
  178.         toolkit = (Toolkit)Class.forName(nm).newInstance();
  179.         } catch (ClassNotFoundException e) {
  180.         throw new AWTError("Toolkit not found: " + nm);
  181.         } catch (InstantiationException e) {
  182.         throw new AWTError("Could not instantiate Toolkit: " + nm);
  183.         } catch (IllegalAccessException e) {
  184.         throw new AWTError("Could not access Toolkit: " + nm);
  185.         }
  186.     }
  187.     return toolkit;
  188.     }
  189.  
  190.     /**
  191.      * Creates an image with the specified image producer.
  192.      * @param producer the image producer to be used
  193.      */
  194.     public abstract Image createImage(ImageProducer producer);
  195. }
  196.